\hypertarget{timer_8h}{}\section{lib/timer.h File Reference}
\label{timer_8h}\index{lib/timer.\+h@{lib/timer.\+h}}


timer functions  


\subsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structTIMERS}{T\+I\+M\+E\+RS}
\begin{DoxyCompactList}\small\item\em user timer struct \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \hyperlink{timer_8h_a492a379b00d0ec04be9cd0994e0b42ae}{M\+A\+X\+\_\+\+T\+I\+M\+E\+R\+\_\+\+C\+NT}~8
\begin{DoxyCompactList}\small\item\em Number of user timer tasks. \end{DoxyCompactList}\item 
\#define \hyperlink{timer_8h_ac0ca52f7bb0e2b7993bbcb75495d7904}{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+NS}~( 1000000000\+L / S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+H\+Z )
\begin{DoxyCompactList}\small\item\em System task in HZ. \end{DoxyCompactList}\item 
\#define \hyperlink{timer_8h_a7e0b78d1697fa3781598373f4e161ea3}{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+US}~( 1000000\+L / S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+H\+Z )
\begin{DoxyCompactList}\small\item\em System task in Microseconds. \end{DoxyCompactList}\item 
\#define \hyperlink{timer_8h_a4068229bfd30e574c7a9f1a8c6687582}{C\+L\+O\+C\+K\+\_\+\+HZ}~\hyperlink{user__config_8h_ab29f444706056b13bca09e97c909bbc5}{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+HZ}
\begin{DoxyCompactList}\small\item\em Clock task in HZ defined as System task. \end{DoxyCompactList}\item 
\#define \hyperlink{timer_8h_a6aacf2441874a27f25ae927bbddf1235}{C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+NS}~\hyperlink{timer_8h_ac0ca52f7bb0e2b7993bbcb75495d7904}{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+NS}
\begin{DoxyCompactList}\small\item\em Clock task in Nanoseconds defined as System Task. \end{DoxyCompactList}\item 
\#define \hyperlink{timer_8h_a1aa52cddadb40365ae68d2c45600d684}{C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+US}~\hyperlink{timer_8h_a7e0b78d1697fa3781598373f4e161ea3}{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+US}
\begin{DoxyCompactList}\small\item\em C\+Lock task in Microseconds defined as System Task. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef \hyperlink{send_8c_a273cf69d639a59973b6019625df33e30}{uint16\+\_\+t} \hyperlink{timer_8h_afeece078c6706f33383bf11bbf584518}{clockid\+\_\+t}
\begin{DoxyCompactList}\small\item\em type of clockid\+\_\+t. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} int \hyperlink{timer_8h_a35f94fb84f1b626d8d1ace062b26c932}{set\+\_\+timers} (void($\ast$handler)(void), int timer)
\begin{DoxyCompactList}\small\item\em Install a user timer task. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} int \hyperlink{timer_8h_a71c3fe0e245c7b08e03a2fe0fbd88844}{kill\+\_\+timer} (int timer)
\begin{DoxyCompactList}\small\item\em Delete \char`\"{}\+Kill\char`\"{} one user timer task. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_a4b27b84577f0a45741aa4b1de370df66}{delete\+\_\+all\+\_\+timers} (void)
\begin{DoxyCompactList}\small\item\em Clear A\+LL user timer tasks. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_ab92d687bae984bd62c3d741f2ba614ed}{subtract\+\_\+timespec} (\hyperlink{time_8h_a062a82a85c72b4a3020130efc37a00cf}{ts\+\_\+t} $\ast$a, \hyperlink{time_8h_a062a82a85c72b4a3020130efc37a00cf}{ts\+\_\+t} $\ast$b)
\begin{DoxyCompactList}\small\item\em subtract a-\/= b timespec $\ast$ structures. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} char $\ast$ \hyperlink{timer_8h_a41fb2edea84c2f17c7c6ad6ff87baeff}{ts\+\_\+to\+\_\+str} (\hyperlink{time_8h_a062a82a85c72b4a3020130efc37a00cf}{ts\+\_\+t} $\ast$val)
\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_a6802af23bc1fe764b975683a0b37fc91}{display\+\_\+ts} (\hyperlink{time_8h_a062a82a85c72b4a3020130efc37a00cf}{ts\+\_\+t} $\ast$val)
\begin{DoxyCompactList}\small\item\em timespec structure in seconds.\+nanoseconds. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_a6beae313733d5f16cb62417d41eaca95}{clock\+\_\+elapsed\+\_\+begin} (void)
\begin{DoxyCompactList}\small\item\em Store current struct timespec in \+\_\+\+\_\+clock\+\_\+elapsed. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_a9f3dff4c1cc1701dc99d7e1d30ffcc06}{clock\+\_\+elapsed\+\_\+end} (char $\ast$msg)
\begin{DoxyCompactList}\small\item\em Subtract and display time difference from clock\+\_\+elapesed\+\_\+begin(). \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_a23ba64ca0da1fe41d4c870ada3e8a04e}{clock\+\_\+clear} (void)
\begin{DoxyCompactList}\small\item\em clear time and timezone to 0. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_abe2823a39b30ff55fe9326f2b5f0741e}{disable\+\_\+timers} (void)
\begin{DoxyCompactList}\small\item\em Disable all timer tasks. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_a0e736ce66a2bc05cc14b7a282fa52b73}{enable\+\_\+timers} (void)
\begin{DoxyCompactList}\small\item\em Enable timer tasks. \end{DoxyCompactList}\item 
void \hyperlink{timer_8h_a7de37276c1b697f865594c7e5f28e961}{execute\+\_\+timers} (void)
\begin{DoxyCompactList}\small\item\em Execute all user timers at S\+Y\+S\+T\+E\+M\+\_\+\+HZ rate. Called by system task. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_aa97274e3b8fdcd900c265d3808d5313c}{clock\+\_\+init} (void)
\item 
void \hyperlink{timer_8h_a182d70e09e9436c9c8a2e81b7597f206}{clock\+\_\+task} (void)
\begin{DoxyCompactList}\small\item\em 1000\+HZ timer task \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_a4a06b0b10204f441d18c79601b4ee13f}{init\+\_\+timers} (void)
\begin{DoxyCompactList}\small\item\em Setup all timers tasksi and enable interrupts. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} int \hyperlink{timer_8h_ab507661341c93c415b27ed9d40839539}{clock\+\_\+getres} (\hyperlink{time_8h_afeece078c6706f33383bf11bbf584518}{clockid\+\_\+t} clk\+\_\+id, struct \hyperlink{structtimespec}{timespec} $\ast$res)
\begin{DoxyCompactList}\small\item\em Read clock time resolution into struct timepec $\ast$ts -\/ P\+O\+S\+IX function. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} int \hyperlink{timer_8h_a4ebca9883466f2cc6fea0547e0e64e79}{clock\+\_\+settime} (\hyperlink{time_8h_afeece078c6706f33383bf11bbf584518}{clockid\+\_\+t} clk\+\_\+id, const struct \hyperlink{structtimespec}{timespec} $\ast$ts)
\begin{DoxyCompactList}\small\item\em Set system clock using seconds and nonoseconds -\/ P\+O\+S\+IX function. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} int \hyperlink{timer_8h_aa6e5b6a9c1fb8bc6e2093fca40600bf5}{clock\+\_\+gettime} (\hyperlink{time_8h_afeece078c6706f33383bf11bbf584518}{clockid\+\_\+t} clk\+\_\+id, struct \hyperlink{structtimespec}{timespec} $\ast$ts)
\begin{DoxyCompactList}\small\item\em Generic \hyperlink{timer_8c_aa6e5b6a9c1fb8bc6e2093fca40600bf5}{clock\+\_\+gettime()} function W\+I\+T\+H\+O\+UT high resolution. \end{DoxyCompactList}\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_a45ccd72c3ad32c4f7a5a8ef74d2653b3}{disable\+\_\+system\+\_\+task} (void)
\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_a9827e02881cff25ff30c35c7d8ed3ac4}{enable\+\_\+system\+\_\+task} (void)
\item 
\hyperlink{earth2wireframe_8c_ad0fe97585b8891f5e4f2b9a6426330a4}{M\+E\+M\+S\+P\+A\+CE} void \hyperlink{timer_8h_a49353e09a3623d95083574b87e9aadc5}{install\+\_\+timers\+\_\+isr} (void)
\end{DoxyCompactItemize}


\subsection{Detailed Description}
timer functions 

\begin{DoxyParagraph}{Copyright \copyright{} 2015 Mike Gore, G\+PL License}

\end{DoxyParagraph}
\begin{DoxyParagraph}{You are free to use this code under the terms of G\+PL}
please retain a copy of this notice in any code you use it in.
\end{DoxyParagraph}
This is free software\+: you can redistribute it and/or modify it under the terms of the G\+NU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but W\+I\+T\+H\+O\+UT A\+NY W\+A\+R\+R\+A\+N\+TY; without even the implied warranty of M\+E\+R\+C\+H\+A\+N\+T\+A\+B\+I\+L\+I\+TY or F\+I\+T\+N\+E\+SS F\+OR A P\+A\+R\+T\+I\+C\+U\+L\+AR P\+U\+R\+P\+O\+SE. See the G\+NU General Public License for more details.

You should have received a copy of the G\+NU General Public License along with this program. If not, see \href{http://www.gnu.org/licenses/}{\tt http\+://www.\+gnu.\+org/licenses/}. 

\subsection{Macro Definition Documentation}
\index{timer.\+h@{timer.\+h}!C\+L\+O\+C\+K\+\_\+\+HZ@{C\+L\+O\+C\+K\+\_\+\+HZ}}
\index{C\+L\+O\+C\+K\+\_\+\+HZ@{C\+L\+O\+C\+K\+\_\+\+HZ}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{C\+L\+O\+C\+K\+\_\+\+HZ}{CLOCK_HZ}}]{\setlength{\rightskip}{0pt plus 5cm}\#define C\+L\+O\+C\+K\+\_\+\+HZ~{\bf S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+HZ}}\hypertarget{timer_8h_a4068229bfd30e574c7a9f1a8c6687582}{}\label{timer_8h_a4068229bfd30e574c7a9f1a8c6687582}


Clock task in HZ defined as System task. 



Definition at line 52 of file timer.\+h.

\index{timer.\+h@{timer.\+h}!C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+NS@{C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+NS}}
\index{C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+NS@{C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+NS}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+NS}{CLOCK_TIC_NS}}]{\setlength{\rightskip}{0pt plus 5cm}\#define C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+NS~{\bf S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+NS}}\hypertarget{timer_8h_a6aacf2441874a27f25ae927bbddf1235}{}\label{timer_8h_a6aacf2441874a27f25ae927bbddf1235}


Clock task in Nanoseconds defined as System Task. 



Definition at line 54 of file timer.\+h.

\index{timer.\+h@{timer.\+h}!C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+US@{C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+US}}
\index{C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+US@{C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+US}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+US}{CLOCK_TIC_US}}]{\setlength{\rightskip}{0pt plus 5cm}\#define C\+L\+O\+C\+K\+\_\+\+T\+I\+C\+\_\+\+US~{\bf S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+US}}\hypertarget{timer_8h_a1aa52cddadb40365ae68d2c45600d684}{}\label{timer_8h_a1aa52cddadb40365ae68d2c45600d684}


C\+Lock task in Microseconds defined as System Task. 



Definition at line 56 of file timer.\+h.

\index{timer.\+h@{timer.\+h}!M\+A\+X\+\_\+\+T\+I\+M\+E\+R\+\_\+\+C\+NT@{M\+A\+X\+\_\+\+T\+I\+M\+E\+R\+\_\+\+C\+NT}}
\index{M\+A\+X\+\_\+\+T\+I\+M\+E\+R\+\_\+\+C\+NT@{M\+A\+X\+\_\+\+T\+I\+M\+E\+R\+\_\+\+C\+NT}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{M\+A\+X\+\_\+\+T\+I\+M\+E\+R\+\_\+\+C\+NT}{MAX_TIMER_CNT}}]{\setlength{\rightskip}{0pt plus 5cm}\#define M\+A\+X\+\_\+\+T\+I\+M\+E\+R\+\_\+\+C\+NT~8}\hypertarget{timer_8h_a492a379b00d0ec04be9cd0994e0b42ae}{}\label{timer_8h_a492a379b00d0ec04be9cd0994e0b42ae}


Number of user timer tasks. 



Definition at line 29 of file timer.\+h.



Referenced by delete\+\_\+all\+\_\+timers(), execute\+\_\+timers(), kill\+\_\+timer(), and set\+\_\+timers().

\index{timer.\+h@{timer.\+h}!S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+NS@{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+NS}}
\index{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+NS@{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+NS}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+NS}{SYSTEM_TASK_TIC_NS}}]{\setlength{\rightskip}{0pt plus 5cm}\#define S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+NS~( 1000000000\+L / S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+H\+Z )}\hypertarget{timer_8h_ac0ca52f7bb0e2b7993bbcb75495d7904}{}\label{timer_8h_ac0ca52f7bb0e2b7993bbcb75495d7904}


System task in HZ. 

System task in Nanoseconds. 

Definition at line 47 of file timer.\+h.



Referenced by clock\+\_\+getres().

\index{timer.\+h@{timer.\+h}!S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+US@{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+US}}
\index{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+US@{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+US}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+US}{SYSTEM_TASK_TIC_US}}]{\setlength{\rightskip}{0pt plus 5cm}\#define S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+T\+I\+C\+\_\+\+US~( 1000000\+L / S\+Y\+S\+T\+E\+M\+\_\+\+T\+A\+S\+K\+\_\+\+H\+Z )}\hypertarget{timer_8h_a7e0b78d1697fa3781598373f4e161ea3}{}\label{timer_8h_a7e0b78d1697fa3781598373f4e161ea3}


System task in Microseconds. 



Definition at line 49 of file timer.\+h.



\subsection{Typedef Documentation}
\index{timer.\+h@{timer.\+h}!clockid\+\_\+t@{clockid\+\_\+t}}
\index{clockid\+\_\+t@{clockid\+\_\+t}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{clockid\+\_\+t}{clockid_t}}]{\setlength{\rightskip}{0pt plus 5cm}typedef {\bf uint16\+\_\+t} {\bf clockid\+\_\+t}}\hypertarget{timer_8h_afeece078c6706f33383bf11bbf584518}{}\label{timer_8h_afeece078c6706f33383bf11bbf584518}


type of clockid\+\_\+t. 



Definition at line 32 of file timer.\+h.



\subsection{Function Documentation}
\index{timer.\+h@{timer.\+h}!clock\+\_\+clear@{clock\+\_\+clear}}
\index{clock\+\_\+clear@{clock\+\_\+clear}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{clock\+\_\+clear(void)}{clock_clear(void)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void clock\+\_\+clear (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a23ba64ca0da1fe41d4c870ada3e8a04e}{}\label{timer_8h_a23ba64ca0da1fe41d4c870ada3e8a04e}


clear time and timezone to 0. 

\begin{DoxySeeAlso}{See also}
\hyperlink{timer_8c_a4ebca9883466f2cc6fea0547e0e64e79}{clock\+\_\+settime()}. 

\hyperlink{time_8c_aba9a1e17f18817099c795d0559d747a8}{settimezone()}.
\end{DoxySeeAlso}
\begin{DoxyReturn}{Returns}
void. 
\end{DoxyReturn}


Definition at line 221 of file timer.\+c.



Referenced by init\+\_\+timers().

\index{timer.\+h@{timer.\+h}!clock\+\_\+elapsed\+\_\+begin@{clock\+\_\+elapsed\+\_\+begin}}
\index{clock\+\_\+elapsed\+\_\+begin@{clock\+\_\+elapsed\+\_\+begin}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{clock\+\_\+elapsed\+\_\+begin(void)}{clock_elapsed_begin(void)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void clock\+\_\+elapsed\+\_\+begin (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a6beae313733d5f16cb62417d41eaca95}{}\label{timer_8h_a6beae313733d5f16cb62417d41eaca95}


Store current struct timespec in \+\_\+\+\_\+clock\+\_\+elapsed. 

\begin{DoxySeeAlso}{See also}
\hyperlink{timer_8c_aa6e5b6a9c1fb8bc6e2093fca40600bf5}{clock\+\_\+gettime()} \hyperlink{posix_8h_a1c3d85ae80df5590fa314acffd8bf840}{P\+O\+S\+IX} function.
\end{DoxySeeAlso}
\begin{DoxyReturn}{Returns}
void 
\end{DoxyReturn}


Definition at line 184 of file timer.\+c.

\index{timer.\+h@{timer.\+h}!clock\+\_\+elapsed\+\_\+end@{clock\+\_\+elapsed\+\_\+end}}
\index{clock\+\_\+elapsed\+\_\+end@{clock\+\_\+elapsed\+\_\+end}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{clock\+\_\+elapsed\+\_\+end(char $\ast$msg)}{clock_elapsed_end(char *msg)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void clock\+\_\+elapsed\+\_\+end (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{msg}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a9f3dff4c1cc1701dc99d7e1d30ffcc06}{}\label{timer_8h_a9f3dff4c1cc1701dc99d7e1d30ffcc06}


Subtract and display time difference from clock\+\_\+elapesed\+\_\+begin(). 


\begin{DoxyItemize}
\item Notes\+: Accuracy is a function of timer resolution, C\+PU overhead and background tasks.
\end{DoxyItemize}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em msg} & User message to proceed Time display.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
void 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{timer_8c_aa6e5b6a9c1fb8bc6e2093fca40600bf5}{clock\+\_\+gettime()}. 

clock\+\_\+elapesed\+\_\+begin(). 
\end{DoxySeeAlso}


Definition at line 200 of file timer.\+c.

\index{timer.\+h@{timer.\+h}!clock\+\_\+getres@{clock\+\_\+getres}}
\index{clock\+\_\+getres@{clock\+\_\+getres}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{clock\+\_\+getres(clockid\+\_\+t clk\+\_\+id, struct timespec $\ast$res)}{clock_getres(clockid_t clk_id, struct timespec *res)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} int clock\+\_\+getres (
\begin{DoxyParamCaption}
\item[{{\bf clockid\+\_\+t}}]{clk\+\_\+id, }
\item[{struct {\bf timespec} $\ast$}]{res}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_ab507661341c93c415b27ed9d40839539}{}\label{timer_8h_ab507661341c93c415b27ed9d40839539}


Read clock time resolution into struct timepec $\ast$ts -\/ P\+O\+S\+IX function. 


\begin{DoxyItemize}
\item Note\+: We ignore clk\+\_\+id 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em clk\+\_\+id} & unused hardware clock index. \\
\hline
\mbox{\tt out}  & {\em res} & timespec resolution result.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success. 

-\/1 on error. 
\end{DoxyReturn}

\end{DoxyItemize}

Definition at line 329 of file timer.\+c.

\index{timer.\+h@{timer.\+h}!clock\+\_\+gettime@{clock\+\_\+gettime}}
\index{clock\+\_\+gettime@{clock\+\_\+gettime}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{clock\+\_\+gettime(clockid\+\_\+t clk\+\_\+id, struct timespec $\ast$ts)}{clock_gettime(clockid_t clk_id, struct timespec *ts)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} int clock\+\_\+gettime (
\begin{DoxyParamCaption}
\item[{{\bf clockid\+\_\+t}}]{clk\+\_\+id, }
\item[{struct {\bf timespec} $\ast$}]{ts}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_aa6e5b6a9c1fb8bc6e2093fca40600bf5}{}\label{timer_8h_aa6e5b6a9c1fb8bc6e2093fca40600bf5}


Generic \hyperlink{timer_8c_aa6e5b6a9c1fb8bc6e2093fca40600bf5}{clock\+\_\+gettime()} function W\+I\+T\+H\+O\+UT high resolution. 

Read clock time into struct timepec $\ast$ts -\/ P\+O\+S\+IX function.


\begin{DoxyItemize}
\item Note\+: We ignore clk\+\_\+id, and include low level counter offsets when available.
\end{DoxyItemize}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em clk\+\_\+id} & unused hardware clock index. \\
\hline
\mbox{\tt out}  & {\em ts} & timespec result.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success. 

-\/1 on error. 
\end{DoxyReturn}


Definition at line 377 of file timer.\+c.



Referenced by clock\+\_\+elapsed\+\_\+begin(), clock\+\_\+elapsed\+\_\+end(), display\+\_\+clock(), gettimeofday(), and time().

\index{timer.\+h@{timer.\+h}!clock\+\_\+init@{clock\+\_\+init}}
\index{clock\+\_\+init@{clock\+\_\+init}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{clock\+\_\+init(void)}{clock_init(void)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void clock\+\_\+init (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_aa97274e3b8fdcd900c265d3808d5313c}{}\label{timer_8h_aa97274e3b8fdcd900c265d3808d5313c}
\index{timer.\+h@{timer.\+h}!clock\+\_\+settime@{clock\+\_\+settime}}
\index{clock\+\_\+settime@{clock\+\_\+settime}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{clock\+\_\+settime(clockid\+\_\+t clk\+\_\+id, const struct timespec $\ast$ts)}{clock_settime(clockid_t clk_id, const struct timespec *ts)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} int clock\+\_\+settime (
\begin{DoxyParamCaption}
\item[{{\bf clockid\+\_\+t}}]{clk\+\_\+id, }
\item[{const struct {\bf timespec} $\ast$}]{ts}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a4ebca9883466f2cc6fea0547e0e64e79}{}\label{timer_8h_a4ebca9883466f2cc6fea0547e0e64e79}


Set system clock using seconds and nonoseconds -\/ P\+O\+S\+IX function. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em clk\+\_\+id} & Hardware timer index used when there are more then one.
\begin{DoxyItemize}
\item Note\+: We ignore clk\+\_\+id for now. 
\end{DoxyItemize}\\
\hline
\mbox{\tt in}  & {\em ts} & struct timespec input.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0. 
\end{DoxyReturn}


Definition at line 345 of file timer.\+c.



Referenced by clock\+\_\+clear(), clock\+\_\+set(), initialize\+\_\+clock(), setdate\+\_\+r(), and settimeofday().

\index{timer.\+h@{timer.\+h}!clock\+\_\+task@{clock\+\_\+task}}
\index{clock\+\_\+task@{clock\+\_\+task}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{clock\+\_\+task(void)}{clock_task(void)}}]{\setlength{\rightskip}{0pt plus 5cm}void clock\+\_\+task (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a182d70e09e9436c9c8a2e81b7597f206}{}\label{timer_8h_a182d70e09e9436c9c8a2e81b7597f206}


1000\+HZ timer task 

\begin{DoxyReturn}{Returns}
void 
\end{DoxyReturn}


Definition at line 276 of file timer.\+c.



Referenced by init\+\_\+timers().

\index{timer.\+h@{timer.\+h}!delete\+\_\+all\+\_\+timers@{delete\+\_\+all\+\_\+timers}}
\index{delete\+\_\+all\+\_\+timers@{delete\+\_\+all\+\_\+timers}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{delete\+\_\+all\+\_\+timers(void)}{delete_all_timers(void)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void delete\+\_\+all\+\_\+timers (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a4b27b84577f0a45741aa4b1de370df66}{}\label{timer_8h_a4b27b84577f0a45741aa4b1de370df66}


Clear A\+LL user timer tasks. 

\begin{DoxyReturn}{Returns}
void 
\end{DoxyReturn}


Definition at line 117 of file timer.\+c.



Referenced by init\+\_\+timers().

\index{timer.\+h@{timer.\+h}!disable\+\_\+system\+\_\+task@{disable\+\_\+system\+\_\+task}}
\index{disable\+\_\+system\+\_\+task@{disable\+\_\+system\+\_\+task}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{disable\+\_\+system\+\_\+task(void)}{disable_system_task(void)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void disable\+\_\+system\+\_\+task (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a45ccd72c3ad32c4f7a5a8ef74d2653b3}{}\label{timer_8h_a45ccd72c3ad32c4f7a5a8ef74d2653b3}


Referenced by disable\+\_\+timers().

\index{timer.\+h@{timer.\+h}!disable\+\_\+timers@{disable\+\_\+timers}}
\index{disable\+\_\+timers@{disable\+\_\+timers}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{disable\+\_\+timers(void)}{disable_timers(void)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void disable\+\_\+timers (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_abe2823a39b30ff55fe9326f2b5f0741e}{}\label{timer_8h_abe2823a39b30ff55fe9326f2b5f0741e}


Disable all timer tasks. 

\begin{DoxyReturn}{Returns}
void 
\end{DoxyReturn}


Definition at line 235 of file timer.\+c.

\index{timer.\+h@{timer.\+h}!display\+\_\+ts@{display\+\_\+ts}}
\index{display\+\_\+ts@{display\+\_\+ts}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{display\+\_\+ts(ts\+\_\+t $\ast$val)}{display_ts(ts_t *val)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void display\+\_\+ts (
\begin{DoxyParamCaption}
\item[{{\bf ts\+\_\+t} $\ast$}]{val}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a6802af23bc1fe764b975683a0b37fc91}{}\label{timer_8h_a6802af23bc1fe764b975683a0b37fc91}


timespec structure in seconds.\+nanoseconds. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em val} & timespec struct we want to display.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
void. 
\end{DoxyReturn}


Definition at line 167 of file timer.\+c.

\index{timer.\+h@{timer.\+h}!enable\+\_\+system\+\_\+task@{enable\+\_\+system\+\_\+task}}
\index{enable\+\_\+system\+\_\+task@{enable\+\_\+system\+\_\+task}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{enable\+\_\+system\+\_\+task(void)}{enable_system_task(void)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void enable\+\_\+system\+\_\+task (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a9827e02881cff25ff30c35c7d8ed3ac4}{}\label{timer_8h_a9827e02881cff25ff30c35c7d8ed3ac4}


Referenced by enable\+\_\+timers().

\index{timer.\+h@{timer.\+h}!enable\+\_\+timers@{enable\+\_\+timers}}
\index{enable\+\_\+timers@{enable\+\_\+timers}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{enable\+\_\+timers(void)}{enable_timers(void)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void enable\+\_\+timers (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a0e736ce66a2bc05cc14b7a282fa52b73}{}\label{timer_8h_a0e736ce66a2bc05cc14b7a282fa52b73}


Enable timer tasks. 

\begin{DoxyReturn}{Returns}
void 
\end{DoxyReturn}


Definition at line 248 of file timer.\+c.



Referenced by init\+\_\+timers().

\index{timer.\+h@{timer.\+h}!execute\+\_\+timers@{execute\+\_\+timers}}
\index{execute\+\_\+timers@{execute\+\_\+timers}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{execute\+\_\+timers(void)}{execute_timers(void)}}]{\setlength{\rightskip}{0pt plus 5cm}void execute\+\_\+timers (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a7de37276c1b697f865594c7e5f28e961}{}\label{timer_8h_a7de37276c1b697f865594c7e5f28e961}


Execute all user timers at S\+Y\+S\+T\+E\+M\+\_\+\+HZ rate. Called by system task. 

\begin{DoxyReturn}{Returns}
void 
\end{DoxyReturn}


Definition at line 261 of file timer.\+c.

\index{timer.\+h@{timer.\+h}!init\+\_\+timers@{init\+\_\+timers}}
\index{init\+\_\+timers@{init\+\_\+timers}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{init\+\_\+timers(void)}{init_timers(void)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void init\+\_\+timers (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a4a06b0b10204f441d18c79601b4ee13f}{}\label{timer_8h_a4a06b0b10204f441d18c79601b4ee13f}


Setup all timers tasksi and enable interrupts. 

\begin{DoxySeeAlso}{See also}
\hyperlink{timer_8c_a182d70e09e9436c9c8a2e81b7597f206}{clock\+\_\+task()} 

\+: \hyperlink{timer__hal_8c}{timer\+\_\+hal.\+c} for hardware dependent interface 
\end{DoxySeeAlso}
\begin{DoxyReturn}{Returns}
void 
\end{DoxyReturn}
See \hyperlink{time_8c}{time.\+c} 

Definition at line 293 of file timer.\+c.



Referenced by setup().

\index{timer.\+h@{timer.\+h}!install\+\_\+timers\+\_\+isr@{install\+\_\+timers\+\_\+isr}}
\index{install\+\_\+timers\+\_\+isr@{install\+\_\+timers\+\_\+isr}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{install\+\_\+timers\+\_\+isr(void)}{install_timers_isr(void)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void install\+\_\+timers\+\_\+isr (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a49353e09a3623d95083574b87e9aadc5}{}\label{timer_8h_a49353e09a3623d95083574b87e9aadc5}


Referenced by init\+\_\+timers().

\index{timer.\+h@{timer.\+h}!kill\+\_\+timer@{kill\+\_\+timer}}
\index{kill\+\_\+timer@{kill\+\_\+timer}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{kill\+\_\+timer(int timer)}{kill_timer(int timer)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} int kill\+\_\+timer (
\begin{DoxyParamCaption}
\item[{int}]{timer}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a71c3fe0e245c7b08e03a2fe0fbd88844}{}\label{timer_8h_a71c3fe0e245c7b08e03a2fe0fbd88844}


Delete \char`\"{}\+Kill\char`\"{} one user timer task. 


\begin{DoxyItemize}
\item \char`\"{}kill\char`\"{} is a common Linux term for ending a process.
\end{DoxyItemize}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em timer} & user timer task index.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
timer on success. 

-\/1 on error. 
\end{DoxyReturn}


Definition at line 100 of file timer.\+c.

\index{timer.\+h@{timer.\+h}!set\+\_\+timers@{set\+\_\+timers}}
\index{set\+\_\+timers@{set\+\_\+timers}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{set\+\_\+timers(void($\ast$handler)(void), int timer)}{set_timers(void(*handler)(void), int timer)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} int set\+\_\+timers (
\begin{DoxyParamCaption}
\item[{void($\ast$)(void)}]{handler, }
\item[{int}]{timer}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a35f94fb84f1b626d8d1ace062b26c932}{}\label{timer_8h_a35f94fb84f1b626d8d1ace062b26c932}


Install a user timer task. 


\begin{DoxyItemize}
\item timer argument is unsused, reserved for timer source.
\end{DoxyItemize}


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em handler)} & function pointer to user task. \\
\hline
\mbox{\tt in}  & {\em timer} & reserved for systems with additional low level hardware timers.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
timer on success. 

-\/1 on error. 
\end{DoxyReturn}


Definition at line 60 of file timer.\+c.



Referenced by init\+\_\+timers(), mmc\+\_\+install\+\_\+timer(), and ms\+\_\+init().

\index{timer.\+h@{timer.\+h}!subtract\+\_\+timespec@{subtract\+\_\+timespec}}
\index{subtract\+\_\+timespec@{subtract\+\_\+timespec}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{subtract\+\_\+timespec(ts\+\_\+t $\ast$a, ts\+\_\+t $\ast$b)}{subtract_timespec(ts_t *a, ts_t *b)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} void subtract\+\_\+timespec (
\begin{DoxyParamCaption}
\item[{{\bf ts\+\_\+t} $\ast$}]{a, }
\item[{{\bf ts\+\_\+t} $\ast$}]{b}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_ab92d687bae984bd62c3d741f2ba614ed}{}\label{timer_8h_ab92d687bae984bd62c3d741f2ba614ed}


subtract a-\/= b timespec $\ast$ structures. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em a} & timespec struct. \\
\hline
\mbox{\tt in}  & {\em b} & timespec struct.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
void. 
\end{DoxyReturn}


Definition at line 135 of file timer.\+c.



Referenced by clock\+\_\+elapsed\+\_\+end().

\index{timer.\+h@{timer.\+h}!ts\+\_\+to\+\_\+str@{ts\+\_\+to\+\_\+str}}
\index{ts\+\_\+to\+\_\+str@{ts\+\_\+to\+\_\+str}!timer.\+h@{timer.\+h}}
\subsubsection[{\texorpdfstring{ts\+\_\+to\+\_\+str(ts\+\_\+t $\ast$val)}{ts_to_str(ts_t *val)}}]{\setlength{\rightskip}{0pt plus 5cm}{\bf M\+E\+M\+S\+P\+A\+CE} char$\ast$ ts\+\_\+to\+\_\+str (
\begin{DoxyParamCaption}
\item[{{\bf ts\+\_\+t} $\ast$}]{val}
\end{DoxyParamCaption}
)}\hypertarget{timer_8h_a41fb2edea84c2f17c7c6ad6ff87baeff}{}\label{timer_8h_a41fb2edea84c2f17c7c6ad6ff87baeff}


Definition at line 155 of file timer.\+c.



Referenced by clock\+\_\+elapsed\+\_\+end(), and display\+\_\+ts().

